package com.github.xiaolyuh.exception;

/**
 * 监控异常
 *
 * @author xuwanglong
 */
public class PromotionMonitorException extends Exception {

    private static final long serialVersionUID = 1L;

    public static final Integer DEFAULT_CODE = 10086;

    /**
     * 错误代码
     */
    private Integer code;

    /**
     * 错误详情
     */
    private String detailMsg;

    public PromotionMonitorException(Integer code, String detailMsg) {
        this(code, detailMsg, new Exception(detailMsg));
    }

    public PromotionMonitorException(Integer code, String detailMsg, Throwable e) {
        super(e);
        this.code = code;
        this.detailMsg = detailMsg;
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDetailMsg() {
        return this.detailMsg;
    }

    public void setDetailMsg(String detailMsg) {
        this.detailMsg = detailMsg;
    }

    public static PromotionMonitorException of(Integer code, String detailMsg){
        return new PromotionMonitorException(code, detailMsg);
    }

    public static PromotionMonitorException of(Integer code, String detailMsg, Throwable e){
        return new PromotionMonitorException(code, detailMsg, e);
    }

    public static PromotionMonitorException of(Throwable e){
        return new PromotionMonitorException(DEFAULT_CODE, e.getMessage(), e);
    }

}
